/*
 * @(#)KeywordRepositoryTest.java $version 2012. 2. 7.
 *
 */

package com.mywep.myalimi.repository.keyword;

import static org.junit.Assert.*;

import java.util.Calendar;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.mywep.myalimi.model.Keyword;

import com.nhncorp.lucy.spring.core.util.DataMap;

/**
 * @author 한지웅
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class KeywordRepositoryTest {
	@Autowired
	private KeywordRepository keywordRepository;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * Test method for {@link com.mywep.myalimi.core.keywords.repository.KeywordRepository#countByExample(com.nhncorp.lucy.spring.core.util.ExtendedMap)}.
	 */
	@Test
	public void testCountByExample() {
		DataMap param = new DataMap();
		int result = keywordRepository.countByExample(param);
		assertTrue(result >= 1);
	}

	/**
	 * Test method for {@link com.mywep.myalimi.core.keywords.repository.KeywordRepository#selectByExample(com.nhncorp.lucy.spring.core.util.ExtendedMap)}.
	 */
	@Test
	public void testSelectByExample() {
		DataMap param = new DataMap();
		param.put("keyword", "웅진에너지");
		List<Keyword> keywords = keywordRepository.selectByExample(param);
		assertEquals(keywords.size(), 1);
		assertEquals(keywords.get(0).getKeyword(), "웅진에너지");
	}

	/**
	 * Test method for {@link com.mywep.myalimi.core.keywords.repository.KeywordRepository#selectByPrimaryKey(com.mywep.myalimi.core.keywords.model.Keyword)}.
	 */
	@Test
	public void testSelectByPrimaryKey() {
		Keyword param = new Keyword();
		param.setKeyword("웅진에너지");
		Keyword keyword = keywordRepository.selectByPrimaryKey(param);
		assertEquals(keyword.getKeyword(), "웅진에너지");
	}

	@Test
	public void testInsert() {
		Keyword param = new Keyword();
		param.setKeyword("test");
		param.setLastAggregateDate(Calendar.getInstance().getTime());
		param.setRegDate(Calendar.getInstance().getTime());
		keywordRepository.insert(param);
		//		assertTrue(result > 0);
	}

}
